package com.example.night.controller;

import com.example.night.data.Order.Order;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.night.service.ApiService.OrderService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/orders")
public class OrderController {
    private final OrderService orderService;

    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }

    @GetMapping("/get_orders")
    public Map<String, Object> getOrders(
            @RequestParam String start_time,
            @RequestParam String end_time,
            @RequestParam String title,
            @RequestParam int status,
            @RequestParam int extend_type,
            @RequestParam String promoterId,
            @RequestParam int page
        ) {

        if (extend_type == 1) {
            extend_type = 2;
        } else if (extend_type == 2) {
            extend_type = 1;
        }
        return orderService.fetchOrders(start_time, end_time, page, title, status, extend_type, promoterId);
    }

}
